﻿using System;

namespace EmbeddedSharp.Core.Function.Maths {
    public class TruncateNode : FuncNode {
        public TruncateNode() {
            base.Value = "truncate";
        }

        public override object Evaluate()
        {
            if (this.Parameters.Count < 1)
            {
                throw new ArgumentException("usage: truncate(number)");
            }

            double result = Convert.ToDouble(
                Parameters[0].Evaluate());

            return System.Math.Truncate(result).ToString();
        }
    }
}
